home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / JTools / Demos / sieve < prev   
Encoding:
Text File  |  1988-09-10  |  778 b   |  28 lines

  1. \ btd changed sive to work the same way as the "C" benchmark and forth 
  2. \ benchmarks  listed in Byte. They print diferently.
  3.  
  4. \ mdh 2/12/87 names changed to prevent redefinition of BENCH.
  5.  
  6. ( SIEVE )
  7.  
  8. DECIMAL 8190 CONSTANT TSIZE
  9.  
  10. VARIABLE FLAGS TSIZE ALLOT
  11.  
  12. : <SIEVE>  ( --- #primes )  FLAGS TSIZE 1 FILL
  13.  0  TSIZE 0
  14.  DO   ( n )  I FLAGS + C@
  15.       IF    I  DUP +  3 +   DUP I +  (  I2*+3 I3*+3 )
  16.            BEGIN  DUP TSIZE <  ( same flag )
  17.            WHILE  0 OVER FLAGS + C! (  i' i'' )   OVER +
  18.            REPEAT 2DROP  1+
  19.       THEN
  20.  LOOP       ;
  21.  
  22. : SIEVE  ." 10 iterations " CR  0   10 0 
  23.   DO     <SIEVE> swap drop 
  24.   LOOP   . ." primes " CR ;
  25.  
  26. \ 31.0 sec  8.00 Mhz  42 sec w/ MMU --- HK Multibus, HKDOS, Indirect-threaded
  27. \ 21.5 sec  Amiga Multi-Forth  Indirect Threaded
  28.